/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package main.java.cn.webrx;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

/**
 * <p>Project: jse2204 - ZipDemo
 * <p>Powered by webrx On 2022-09-23 11:19:41
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class ZipDemo {
    public static void main(String[] args) throws Exception{

        //建立ZipOutputStream
        ZipOutputStream zos = new ZipOutputStream(new FileOutputStream("my.zip",true));

        zos.putNextEntry(new ZipEntry("a.txt"));
        zos.write(new FileInputStream("a.txt").readAllBytes());

        zos.putNextEntry(new ZipEntry("b.txt"));
        zos.write(new FileInputStream("b.txt").readAllBytes());

        zos.putNextEntry(new ZipEntry("d.txt"));
        zos.write(new FileInputStream("d.txt").readAllBytes());

        zos.putNextEntry(new ZipEntry("src.md"));
        zos.write(new FileInputStream("src.md").readAllBytes());

        zos.putNextEntry(new ZipEntry("g1.jpg"));
        zos.write(new FileInputStream("c:/abc/g1.jpg").readAllBytes());

        zos.close();
    }
}
